-2005-09-09 Øyvind Kolås <pippin@gimp.org>
+2005-08-09 Øyvind Kolås <pippin@gimp.org>
+
+ * babl/Makefile-mini: CFLAGS = -Werror -Wall ....
+ * babl/babl-classes.[ch]: BablPixelFormat removed unused pointers
+ to lists of conversions. Added BablReferenceFish. Renamed kind/
+ instance.type to class_type/instance.class_type. Removed mostly
+ unused macro's and expanded them in source
+
+ * babl/babl-component.c
+ * babl/babl-conversion.c
+ * babl/babl-db.h
+ * babl/babl-fish.c
+ * babl/babl-image.c
+ * babl/babl-introspect.c
+ * babl/babl-model.c
+ * babl/babl-pixel-format.c
+ * babl/babl-sampling.c
+
+ * babl/babl-type.c: removed switch statement since all enums are
+ handled equally.
+
+ * babl/tests/Makefile.am: added nop and introspect to TESTS, not
+ actual tests yet, but at least a segfault will cause make check to
+ fail.
+
+2005-08-09 Øyvind Kolås <pippin@gimp.org>
* autogen.sh: make autogen also run make
* babl/babl-classes.h: added define macro usable for sampling and
* babl/babl-fish.[ch]: cleanup of stub class
* babl/babl-sampling.h: simplification of header using a define.
-2005-09-09 Øyvind Kolås <pippin@gimp.org>
+2005-08-09 Øyvind Kolås <pippin@gimp.org>
* babl/babl-conversion.c: indentation cleanup.
-2005-09-09 Øyvind Kolås <pippin@gimp.org>
+2005-08-09 Øyvind Kolås <pippin@gimp.org>
* babl/babl-ids: added BABL_LUMINANCE_GAMMA_2_2,
BABL_LUMINANCE_MUL_ALPHA, BABL_GRAYSCALE_GAMMA_2_2,
# This makeile is used for more rapid test compilations than
# autofoo allows, it will not build a usable libray though.
-default: clean all
TARGETS = \
../tests/nop \
../tests/introspect
-CFLAGS = -Wall -g -O1 -I./babl-base -I. -I..
+default: $(TARGETS)
+
+CFLAGS = -Wall -Werror -g -O1 -I./babl-base -I. -I..
BABL_OBJECTS= \
babl.o \
"BablConversionPixelFormatPlanar",
"BablConversionPixelFormatPlanar",
"BablFish",
+ "BablReferenceFish",
+ "BablImage",
"BablCeiling"
};
BABL_CONVERSION_PIXEL_FORMAT_PLANAR,
BABL_FISH,
+ BABL_FISH_REFERENCE,
BABL_IMAGE,
BABL_SKY
/* common header for any item inserted into database */
typedef struct
{
- BablClassType type;
+ BablClassType class_type;
int id; /*< a numerical id, look at 'babl-ids.h' for the reserved
ones */
char *name; /*< the name this type exists under */
BablComponent **component;
BablType **type;
BablSampling **sampling;
- BablConversion *to_conversions;
- BablConversion *from_conversions;
} BablPixelFormat;
typedef struct
union Babl *destination;
} BablFish;
+typedef struct
+{
+ BablFish fish;
+ BablConversion *type_to_double;
+ BablConversion *model_to_rgba;
+ BablConversion *rgba_to_model;
+ BablConversion *double_to_type;
+} BablReferenceFish;
+
typedef union
{
- BablClassType kind;
- BablInstance instance;
- BablType type;
- BablSampling sampling;
- BablComponent component;
- BablModel model;
- BablPixelFormat pixel_format;
- BablConversion conversion;
- BablFish fish;
- BablImage image;
+ BablClassType class_type;
+ BablInstance instance;
+ BablType type;
+ BablSampling sampling;
+ BablComponent component;
+ BablModel model;
+ BablPixelFormat pixel_format;
+ BablConversion conversion;
+ BablFish fish;
+ BablReferenceFish reference_fish;
+ BablImage image;
} Babl;
-#define BABL_NAME(obj) (((Babl*)(obj))->instance.name)
-#define BABL_INSTANCE_TYPE(obj) (((Babl*)(obj))->kind)
-
#define BABL_IS_BABL(obj)\
-(NULL==(obj)?0:BABL_CLASS_TYPE_IS_VALID(BABL_INSTANCE_TYPE(obj)))
-
-#define BABL_IS_OF_KIND(obj,kind) \
- (!BABL_IS_BABL(obj)?0:kind==BABL_INSTANCE_TYPE(obj)?1:0)
-
-#define BABL_IS_INSTANCE(obj) BABL_IS_OF_KIND(obj,BABL_TYPE)
-#define BABL_IS_TYPE(obj) BABL_IS_OF_KIND(obj,BABL_TYPE)
-#define BABL_IS_COMPONENT(obj) BABL_IS_OF_KIND(obj,BABL_COMPONENT)
-#define BABL_IS_SAMPLING(obj) BABL_IS_OF_KIND(obj,BABL_SAMPLING)
-#define BABL_IS_PIXEL_FORMAT(obj) BABL_IS_OF_KIND(obj,BABL_PIXEL_FORMAT)
+(NULL==(obj)?0:BABL_CLASS_TYPE_IS_VALID(((Babl*)(obj))->class_type))
typedef int (*BablEachFunction) (Babl *entry,
void *data);
int chroma,
int alpha)
{
- BablComponent *self;
+ Babl *self;
- self = babl_calloc (sizeof (BablComponent), 1);
- self->instance.type = BABL_COMPONENT;
- self->instance.id = id;
- self->instance.name = babl_strdup (name);
- self->luma = luma;
- self->chroma = chroma;
- self->alpha = alpha;
+ self = babl_calloc (sizeof (BablComponent), 1);
+ self->class_type = BABL_COMPONENT;
+ self->instance.id = id;
+ self->instance.name = babl_strdup (name);
+ self->component.luma = luma;
+ self->component.chroma = chroma;
+ self->component.alpha = alpha;
- return self;
+ return (BablComponent*) self;
}
BablComponent *
{
Babl *babl = (Babl*)arg;
- switch (BABL_INSTANCE_TYPE (arg))
+ switch (babl->class_type)
{
case BABL_TYPE:
case BABL_INSTANCE:
case BABL_CONVERSION_PIXEL_FORMAT:
case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
case BABL_FISH:
+ case BABL_FISH_REFERENCE:
case BABL_IMAGE:
babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->instance.type));
+ __FUNCTION__, babl_class_name (babl->class_type));
break;
case BABL_SKY: /* shut up compiler */
break;
BablFuncPlanar planar,
BablFuncPlanarBit planar_bit)
{
- BablConversion *self = NULL;
+ Babl *self = NULL;
/* destination is of same type as source */
- switch (BABL_INSTANCE_TYPE (source))
+ switch (source->class_type)
{
case BABL_TYPE:
if (linear)
{
self = babl_calloc (sizeof (BablConversionType), 1);
- self->instance.type = BABL_CONVERSION_TYPE;
- self->function.linear = linear;
+ self->class_type = BABL_CONVERSION_TYPE;
+ self->conversion.function.linear = linear;
}
else if (planar)
{
self = babl_calloc (sizeof (BablConversionTypePlanar), 1);
- self->instance.type = BABL_CONVERSION_TYPE_PLANAR;
- self->function.planar = planar;
+ self->class_type = BABL_CONVERSION_TYPE_PLANAR;
+ self->conversion.function.planar = planar;
}
else if (planar_bit)
{
else if (planar)
{
self = babl_calloc (sizeof (BablConversionModelPlanar), 1);
- self->instance.type = BABL_CONVERSION_MODEL_PLANAR;
- self->function.planar = planar;
+ self->class_type = BABL_CONVERSION_MODEL_PLANAR;
+ self->conversion.function.planar = planar;
}
else if (planar_bit)
{
if (linear)
{
self = babl_calloc (sizeof (BablConversionPixelFormat), 1);
- self->instance.type = BABL_CONVERSION_PIXEL_FORMAT;
- self->function.linear = linear;
+ self->class_type = BABL_CONVERSION_PIXEL_FORMAT;
+ self->conversion.function.linear = linear;
}
else if (planar)
{
self = babl_calloc (sizeof (BablConversionPixelFormatPlanar), 1);
- self->instance.type = BABL_CONVERSION_PIXEL_FORMAT_PLANAR;
- self->function.planar = planar;
+ self->class_type = BABL_CONVERSION_PIXEL_FORMAT_PLANAR;
+ self->conversion.function.planar = planar;
}
else if (planar_bit)
{
return NULL;
}
- self->instance.id = id;
- self->instance.name = babl_strdup (name);
- self->source = (union Babl*)source;
- self->destination = (union Babl*)destination;
- self->time_cost = time_cost;
- self->loss = loss;
+ self->instance.id = id;
+ self->instance.name = babl_strdup (name);
+ self->conversion.source = (union Babl*)source;
+ self->conversion.destination = (union Babl*)destination;
+ self->conversion.time_cost = time_cost;
+ self->conversion.loss = loss;
babl_add_ptr_to_list ((void ***)&(source->type.from), self);
babl_add_ptr_to_list ((void ***)&(destination->type.to), self);
const char *sample_type = "unknwon";
if (db[0])
- sample_type = babl_class_name (db[0]->instance.type);
+ sample_type = babl_class_name (db[0]->class_type);
babl_log ("%s(\"%s\"): failed (query performed on a %s database)",
__FUNCTION__, name, sample_type);
}
Babl *source,
Babl *destination)
{
- BablFish *self = NULL;
+ Babl *self = NULL;
- self = babl_calloc (sizeof (BablFish), 1);
- self->instance.type = BABL_FISH;
+ assert (BABL_IS_BABL (source));
+ assert (BABL_IS_BABL (destination));
- self->instance.id = 0;
- self->instance.name = "Fishy";
- self->source = (union Babl*)source;
- self->destination = (union Babl*)destination;
+ self = babl_calloc (sizeof (BablFish), 1);
+ self->class_type = BABL_FISH;
+ self->instance.id = 0;
+ self->instance.name = "Fishy";
+ self->fish.source = (union Babl*)source;
+ self->fish.destination = (union Babl*)destination;
- assert (BABL_IS_BABL (self->source));
- assert (BABL_IS_BABL (self->destination));
-
- if ((BablFish*) db_insert ( (Babl*)self) == self)
+ if (db_insert (self) == self)
{
- return self;
+ return (BablFish*)self;
}
else
{
- each_babl_fish_destroy ( (Babl*)self, NULL);
+ each_babl_fish_destroy (self, NULL);
return NULL;
}
BablSampling **band_sampling,
BablType **band_type)
{
- BablPixelFormat *self;
+ Babl *self;
int band;
self = babl_calloc (sizeof (BablPixelFormat), 1);
- self->instance.type = BABL_PIXEL_FORMAT;
+ self->class_type = BABL_PIXEL_FORMAT;
self->instance.id = id;
self->instance.name = babl_strdup (name);
- self->bands = bands;
- self->planar = planar;
+ self->pixel_format.bands = bands;
+ self->pixel_format.planar = planar;
- self->component = babl_malloc (sizeof (BablComponent*) * (bands+1));
- self->type = babl_malloc (sizeof (BablType*) * (bands+1));
- self->sampling = babl_malloc (sizeof (BablSampling*) * (bands+1));
+ self->pixel_format.component = babl_malloc (sizeof (BablComponent*) * (bands+1));
+ self->pixel_format.type = babl_malloc (sizeof (BablType*) * (bands+1));
+ self->pixel_format.sampling = babl_malloc (sizeof (BablSampling*) * (bands+1));
for (band=0; band < bands; band++)
{
- self->component[band] = band_component[band];
- self->type[band] = band_type[band];
- self->sampling[band] = band_sampling[band];
+ self->pixel_format.component[band] = band_component[band];
+ self->pixel_format.type[band] = band_type[band];
+ self->pixel_format.sampling[band] = band_sampling[band];
}
- self->component[band] = NULL;
- self->type[band] = NULL;
- self->sampling[band] = NULL;
+ self->pixel_format.component[band] = NULL;
+ self->pixel_format.type[band] = NULL;
+ self->pixel_format.sampling[band] = NULL;
- return self;
+ return (BablPixelFormat*)self;
}
BablPixelFormat *
{
Babl *babl = (Babl*)arg;
- switch (BABL_INSTANCE_TYPE (arg))
+ switch (babl->class_type)
{
case BABL_TYPE:
current_type = (BablType*) babl;
case BABL_INSTANCE:
case BABL_MODEL:
babl_log ("%s(): %s not handled in pixel format yet",
- __FUNCTION__, babl_class_name (babl->instance.type));
+ __FUNCTION__, babl_class_name (babl->class_type));
break;
case BABL_PIXEL_FORMAT:
case BABL_CONVERSION_PIXEL_FORMAT:
case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
case BABL_FISH:
+ case BABL_FISH_REFERENCE:
case BABL_IMAGE:
babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->instance.type));
+ __FUNCTION__, babl_class_name (babl->class_type));
break;
case BABL_SKY: /* shut up compiler */
break;
int *pitch,
int *stride)
{
- BablImage *self;
+ Babl *self;
int band;
self = babl_calloc (sizeof (BablImage), 1);
- self->instance.type = BABL_IMAGE;
+ self->class_type = BABL_IMAGE;
self->instance.id = 0;
self->instance.name = "babl image";
- self->bands = bands;
+ self->image.bands = bands;
- self->component = babl_malloc (sizeof (BablComponent*) * (bands+1));
- self->data = babl_malloc (sizeof (void*) * (bands+1));
- self->pitch = babl_malloc (sizeof (int) * (bands+1));
- self->stride = babl_malloc (sizeof (int) * (bands+1));
+ self->image.component = babl_malloc (sizeof (BablComponent*) * (bands+1));
+ self->image.data = babl_malloc (sizeof (void*) * (bands+1));
+ self->image.pitch = babl_malloc (sizeof (int) * (bands+1));
+ self->image.stride = babl_malloc (sizeof (int) * (bands+1));
for (band=0; band < bands; band++)
{
- self->component[band] = component[band];
- self->data[band] = data[band];
- self->pitch[band] = pitch[band];
- self->stride[band] = stride[band];
+ self->image.component[band] = component[band];
+ self->image.data[band] = data[band];
+ self->image.pitch[band] = pitch[band];
+ self->image.stride[band] = stride[band];
}
- self->component[band] = NULL;
- self->data[band] = NULL;
- self->pitch[band] = 0;
- self->stride[band] = 0;
+ self->image.component[band] = NULL;
+ self->image.data[band] = NULL;
+ self->image.pitch[band] = 0;
+ self->image.stride[band] = 0;
- return self;
+ return (BablImage*) self;
}
BablImage *
{
Babl *babl = (Babl*)arg;
- if (babl->instance.type == BABL_COMPONENT)
+ if (babl->class_type == BABL_COMPONENT)
{
new_component = (BablComponent *)babl;
}
else
{
babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->instance.type));
+ __FUNCTION__, babl_class_name (babl->class_type));
return NULL;
}
}
"BablConversionPixelFormatPlanar",
"BablConversionPixelFormatPlanar",
"BablFish",
+ "BablReferenceFish",
+ "BablImage",
"BablCeiling"
};
for (i=0; i< babl->model.components; i++)
{
babl_log ("\t\tindex[%i] = '%s'",
- i, BABL_NAME (babl->model.component[i]));
+ i, ((Babl*)babl->model.component[i])->instance.name );
}
}
for (i=0; i< babl->pixel_format.bands; i++)
{
babl_log ("\t\tband[%i] type='%s' component='%s'",
- i, BABL_NAME (babl->pixel_format.type[i]),
- BABL_NAME (babl->pixel_format.component[i]));
+ i, ( (Babl*)(babl->pixel_format.type[i] ))->instance.name,
+ ( (Babl*)(babl->pixel_format.component[i]))->instance.name);
}
}
babl_log ("\t'%s'\t%i\t%s",
babl->instance.name,
babl->instance.id,
- babl_class_name (babl->instance.type));
- switch (babl->instance.type)
+ babl_class_name (babl->class_type));
+ switch (babl->class_type)
{
case BABL_TYPE:
type_introspect (babl);
int components,
BablComponent **component)
{
- BablModel *self;
- int i;
+ Babl *self;
+ int i;
self = babl_calloc (sizeof (BablModel), 1);
- self->instance.type = BABL_MODEL;
- self->instance.id = id;
- self->instance.name = babl_strdup (name);
-
- self->components = components;
-
- self->component = babl_malloc (sizeof (BablComponent*) * (components+1));
+ self->class_type = BABL_MODEL;
+ self->instance.id = id;
+ self->instance.name = babl_strdup (name);
+ self->model.components = components;
+ self->model.component = babl_malloc (sizeof (BablComponent*) * (components+1));
for (i=0; i < components; i++)
{
- self->component[i] = component[i];
+ self->model.component[i] = component[i];
}
- self->component[i] = NULL;
+ self->model.component[i] = NULL;
- return self;
+ return (BablModel*)self;
}
BablModel *
{
Babl *babl = (Babl*)arg;
- switch (BABL_INSTANCE_TYPE (arg))
+ switch (babl->class_type)
{
case BABL_COMPONENT:
band_component [components] = (BablComponent*) babl;
case BABL_CONVERSION_PIXEL_FORMAT:
case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
case BABL_FISH:
+ case BABL_FISH_REFERENCE:
case BABL_IMAGE:
babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->instance.type));
+ __FUNCTION__, babl_class_name (babl->class_type));
break;
case BABL_SKY: /* shut up compiler */
break;
BablSampling **band_sampling,
BablType **band_type)
{
- BablPixelFormat *self;
+ Babl *self;
int band;
self = babl_calloc (sizeof (BablPixelFormat), 1);
- self->instance.type = BABL_PIXEL_FORMAT;
+ self->class_type = BABL_PIXEL_FORMAT;
self->instance.id = id;
self->instance.name = babl_strdup (name);
- self->bands = bands;
- self->planar = planar;
+ self->pixel_format.bands = bands;
+ self->pixel_format.planar = planar;
- self->component = babl_malloc (sizeof (BablComponent*) * (bands+1));
- self->type = babl_malloc (sizeof (BablType*) * (bands+1));
- self->sampling = babl_malloc (sizeof (BablSampling*) * (bands+1));
+ self->pixel_format.component = babl_malloc (sizeof (BablComponent*) * (bands+1));
+ self->pixel_format.type = babl_malloc (sizeof (BablType*) * (bands+1));
+ self->pixel_format.sampling = babl_malloc (sizeof (BablSampling*) * (bands+1));
for (band=0; band < bands; band++)
{
- self->component[band] = band_component[band];
- self->type[band] = band_type[band];
- self->sampling[band] = band_sampling[band];
+ self->pixel_format.component[band] = band_component[band];
+ self->pixel_format.type[band] = band_type[band];
+ self->pixel_format.sampling[band] = band_sampling[band];
}
- self->component[band] = NULL;
- self->type[band] = NULL;
- self->sampling[band] = NULL;
+ self->pixel_format.component[band] = NULL;
+ self->pixel_format.type[band] = NULL;
+ self->pixel_format.sampling[band] = NULL;
- return self;
+ return (BablPixelFormat*)self;
}
BablPixelFormat *
{
Babl *babl = (Babl*)arg;
- switch (BABL_INSTANCE_TYPE (arg))
+ switch (babl->class_type)
{
case BABL_TYPE:
current_type = (BablType*) babl;
case BABL_INSTANCE:
case BABL_MODEL:
babl_log ("%s(): %s not handled in pixel format yet",
- __FUNCTION__, babl_class_name (babl->instance.type));
+ __FUNCTION__, babl_class_name (babl->class_type));
break;
case BABL_PIXEL_FORMAT:
case BABL_CONVERSION_PIXEL_FORMAT:
case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
case BABL_FISH:
+ case BABL_FISH_REFERENCE:
case BABL_IMAGE:
babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->instance.type));
+ __FUNCTION__, babl_class_name (babl->class_type));
break;
case BABL_SKY: /* shut up compiler */
break;
for (vertical=VERTICAL_MIN; vertical<=VERTICAL_MAX; vertical++)
{
int index= (vertical-VERTICAL_MIN) * VERTICAL_MAX + (horizontal - HORIZONTAL_MIN);
- db[index].instance.type = BABL_SAMPLING;
+ db[index].instance.class_type = BABL_SAMPLING;
db[index].instance.id = 0;
db[index].instance.name = "Samplings have no name";
db[index].horizontal = horizontal;
if (0 == babl->instance.id)
{
babl_log ("%s\t'%s' has id==0",
- babl_class_name (babl->instance.type), babl->instance.name);
+ babl_class_name (babl->class_type), babl->instance.name);
}
return 0;
}
#include "babl-internal.h"
#include "babl-db.h"
-
#include <string.h>
#include <stdarg.h>
int id,
int bits)
{
- BablType *self;
+ Babl *self;
self = babl_calloc (sizeof (BablType), 1);
- self->instance.type = BABL_TYPE;
+ self->class_type = BABL_TYPE;
self->instance.id = id;
self->instance.name = babl_strdup (name);
- self->bits = bits;
+ self->type.bits = bits;
- return self;
+ return (BablType*)self;
}
BablType *
{
Babl *babl = (Babl*)arg;
- switch (BABL_INSTANCE_TYPE (arg))
- {
- case BABL_TYPE:
- case BABL_INSTANCE:
- case BABL_COMPONENT:
- case BABL_MODEL:
- case BABL_PIXEL_FORMAT:
- case BABL_SAMPLING:
-
- case BABL_CONVERSION:
- case BABL_CONVERSION_TYPE:
- case BABL_CONVERSION_TYPE_PLANAR:
- case BABL_CONVERSION_MODEL_PLANAR:
- case BABL_CONVERSION_PIXEL_FORMAT:
- case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
- case BABL_FISH:
- babl_log ("%s(): %s unexpected",
- __FUNCTION__, babl_class_name (babl->instance.type));
- break;
- case BABL_SKY: /* shut up compiler */
- break;
- }
+ babl_log ("%s(): %s unexpected",
+ __FUNCTION__, babl_class_name (babl->class_type));
}
/* if we didn't point to a babl, we assume arguments to be strings */
else if (!strcmp (arg, "id"))
EXTRA_DIST= \
.cvsignore
+
+TESTS=nop introspect